<div class="entity-add-actions-wrapper" style="display:inline-block; text-align:left;" *ngIf="this.totalActions> 0">
  <button 
    style="height:37px; margin-top:-1px;" 
    mat-button color="primary" 
    [matMenuTriggerFor]="menu" 
    class="menu-toggle" 
    *ngIf="this.totalActions> 1; else elseBlock"  
    matTooltip="{{ this.menuTriggerMessage | translate}}"
    ix-auto
    ix-auto-type="button"
    ix-auto-identifier="{{entity.conf.title}}_ACTIONS">
    <span>{{"Actions" | translate}} <mat-icon class="menu-caret ">arrow_drop_down</mat-icon></span>
  </button>
  <mat-menu #menu="matMenu" overlapTrigger="false">
    <button mat-menu-item 
      (click)="this.entity.doAdd()" 
      *ngIf="this.entity.conf.route_add" 
      id="add_action_button"
      ix-auto
      ix-auto-type="button"
      ix-auto-identifier="{{entity.conf.title}}_ADD">
      <span>{{"Add" | translate }}</span>
    </button>
    <button id="add_action_button_{{action?.label}}" 
      *ngFor="let action of actions" 
      mat-menu-item 
      (click)="action.onClick()"
      ix-auto
      ix-auto-type="button"
      ix-auto-identifier="{{entity.conf.title}}_{{action.label}}">
      <span>{{action.label | translate}}</span>
    </button>
  </mat-menu>

  <ng-template #elseBlock>
    <!--When there is no route_add -->
    <button 
      [disabled]="entity.conf.addBtnDisabled" 
      mat-button color="primary" 
      (click)="this.entity.doAdd()" 
      *ngIf="this.entity.conf.route_add" 
      matTooltip="{{this.entity.conf.route_addd_tooltip | translate}}" 
      id="add_action_button"
      ix-auto
      ix-auto-type="button"
      ix-auto-identifier="{{entity.conf.title}}_ADD">{{"Add" | translate}}
    </button>
    <button 
      id="add_action_button_{{action?.label}}" 
      mat-button color="primary" 
      *ngIf="!this.entity.conf.route_add && this.totalActions== 1" 
      (click)="this.actions[0].onClick()"  
      matTooltip="{{actions[0].label | translate}}"
      ix-auto
      ix-auto-type="button"
      ix-auto-identifier="{{entity.conf.title}}_{{this.actions[0].label}}">
      <span>{{this.actions[0].label | translate }}</span> 
      <!-- <span> &nbsp; {{this.actions.length}}</span> -->
    </button>
  </ng-template>
</div>
